package com.wlc.servlet;

import java.io.IOException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



/**
 * Servlet implementation class Demo1
 */
@WebServlet("/Demo1")
public class Demo1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
  
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Enumeration<String> en=request.getHeaderNames();
		while(en.hasMoreElements())
		{
			String name=en.nextElement();
			String value=request.getHeader(name);
		}
		String name=request.getParameter("username");
		String address=request.getParameter("password");
		System.out.println();
		System.out.println("-------------------------------");
		Map<String, String[]>  map=request.getParameterMap();
		Set<String> set=map.keySet();
		Iterator<String> it=set.iterator();
		System.out.println(it.hasNext());
		while(it.hasNext())
		{
			
			String key=it.next();
			String[] arr=map.get(key);
			String value =arr[0];
			System.out.println("name"+key+"value"+value);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
